<?php
/**
 * Created by PhpStorm.
 * BuyUser: USER
 * Date: 2018/11/12
 * Time: 11:08
 */

namespace app\controllers;

use yii\web\Controller;
use common\widgets\Tool;
use Yii;

class BuyUserController extends BaseController
{
    /** @var \common\logics\buyuser\BuyUserLogic $BuyUserService */
    private $BuyUserService;

    /** @var \common\logics\test\TestLogic $testService */
    private $testService;

    public function init()
    {
        $this->BuyUserService = Yii::$container->get('BuyUserService');
        $this->testService = Yii::$container->get('testService');
        parent::init();
    }

    //买手注册方法
    public function actionRegBuyUser()
    {
        $param = [
            'inviter_id' => Yii::$app->request->post('inviter_id',0),           //邀请人id
            'phone' => Yii::$app->request->post('phone',''),            //电话号码
            'password' => Yii::$app->request->post('password',''),      //密码
            'pwd_confirm'  => Yii::$app->request->post('pwd_confirm',''),//确认密码
            'qq' => Yii::$app->request->post('qq',''),                  // qq
            'wx' => Yii::$app->request->post('wx',''),                  //wx
            "reg_code" => Yii::$app->request->post("reg_code",''),      //注册码
            'verifycode' => Yii::$app->request->post('verifycode',''),  //验证码
        ];
        $result = $this->BuyUserService->register($param);
        return $result;
    }
    //外部网址商家注册
    public function actionRegBusTest()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),            //电话号码
            'password' => Yii::$app->request->post('password',''),      //密码
            'pwd_confirm'  => Yii::$app->request->post('pwd_confirm',''),//确认密码
            'qq' => Yii::$app->request->post('qq',''),                  // qq
            'wx' => Yii::$app->request->post('wx',''),                  //wx
        ];
        $result = $this->BuyUserService->busReg($param);
        return $result;
    }
    //外部网址买手注册
    public function actionRegBuyTest()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),            //电话号码
            'password' => Yii::$app->request->post('password',''),      //密码
            'pwd_confirm'  => Yii::$app->request->post('pwd_confirm',''),//确认密码
            'qq' => Yii::$app->request->post('qq',''),                  // qq
            'wx' => Yii::$app->request->post('wx',''),                  //wx
        ];
        $result = $this->BuyUserService->buyReg($param);
        return $result;
    }
    //外部网址商家登陆
    public function actionBusLogin()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),    //手机号码
            'password' => Yii::$app->request->post('password',''),//密码
        ];
        $result = $this->BuyUserService->busLogin($param);
        return $result;
    }
    //外部网站买手登陆
    public function actionBuyLogin()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),    //手机号码
            'password' => Yii::$app->request->post('password',''),//密码
        ];
        $result = $this->BuyUserService->buyLogin($param);
        return $result;
    }


    //账号密码登陆方法
    public function actionLoginPhone()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),    //手机号码
            'password' => Yii::$app->request->post('password',''),//密码
        ];
        $result = $this->BuyUserService->login($param);
        return $result;
    }

    //手机验证码登陆
    public function actionLoginCode()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),            //手机号码
            'verifycode' => Yii::$app->request->post('verifycode',''),  //短信验证码
        ];
        $result = $this->BuyUserService->loginCode($param);
        return $result;
    }

    //人机验证
    public function actionCaptcha()
    {
        $data = Yii::$app->request->post();
        $result = $this->BuyUserService->captcha($data);
        return $result;
    }

    //修改密码
    public function actionModifyPassword()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),
            'sms_code' => Yii::$app->request->post('sms_code',''),
            'newPwd' => Yii::$app->request->post('newPwd',''),
            'newPwd_confirm' => Yii::$app->request->post('newPwd_confirm','')
        ];
        $result = $this->BuyUserService->modifyPassword($param);
        return $result;
    }

    //忘记密码
    public function actionForgetPassword()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),
            'verifycode' => Yii::$app->request->post('verifycode',''),
            'newPwd' => Yii::$app->request->post('newPwd',''),
            'newPwd_confirm' => Yii::$app->request->post('newPwd_confirm','')
        ];
        $result = $this->BuyUserService->forgetPassword($param);
        return $result;
    }
    //修改qq与微信
    public function actionModifyQqWx()
    {
        $param = [
            'buy_id' => Yii::$app->request->post('buy_id',0),  //用户id
            'qq' => Yii::$app->request->post('qq',''),          //qq号
            'wx' => Yii::$app->request->post('wx',''),          //微信号
        ];
        $result = $this->BuyUserService->modifyQQWx($param);
        return $result;
    }
    //设置支付密码
    public function actionSetPayPwd()
    {
        $param = [
            'phone' => Yii::$app->request->post('phone',''),
            'sms_code' => Yii::$app->request->post('sms_code',''),
            'newPwd' => Yii::$app->request->post('newPwd',''),
            'newPwd_confirm' => Yii::$app->request->post('newPwd_confirm','')
        ];
        $result = $this->BuyUserService->setPayPwd($param);
        return $result;
    }
    //商家详情
    public function actionGetBusinessMessage()
    {
        $param = [
            "bus_id" => Yii::$app->request->post("bus_id",0),               //买手id
            "safetyCode" => Yii::$app->request->post("safetyCode",""),      //安全码
        ];
        $result = $this->BuyUserService->getMessage($param);
        return $result;
    }

}